<script type="text/javascript">
	var $highlightadd_content = $("#highlightadd_content");

	$(document).ready(function () {
		var theme = 'fresh';
		$('.field_input').addClass('jqx-input');
		$('.field_input').addClass('field');
		$('.field_input').addClass('jqx-rc-all');

		var highlightadd_save = $("#highlightadd_save");
		var highlightadd_cancel = $("#highlightadd_cancel");
		var highlightpost_id = $("#highlightpost_id");
		var highlightpost_task = $("#highlightpost_task");
		var highlightpost_judul = $("#highlightpost_judul");
		var highlightpost_gambar = $("#highlightpost_gambar");
		var highlightpost_gambarname = $("#highlightpost_gambarname");
		var highlightpost_isi = $("#highlightpost_isi");
		var highlightpost_link = $("#highlightpost_link");


		highlightadd_save.jqxButton({ theme : theme, width : '70px', height : '18px' });
		highlightadd_cancel.jqxButton({ width : '70px' , height : '18px' ,theme : theme });

		highlightpost_gambar.fileupload({
			dataType: 'json',
			formData : function(form){
				return [{ name: 'upload', value: '!@#$%^&*())_+=-0876563211' }];
			},
			done: function (e, data){
				var text = "";
				$.each(data.result, function (index, file) {
					text = text + file.name;
					$("#highlightpost_gambarname").val(text);
				});
			}
		});
		/* function */
		highlightadd_cancel.click(function(){
			$('#mainpanelcontent').empty();
			$('<img src="./images/loader.gif" style="margin:50px auto auto 390px;">').appendTo('#contents');
			$('#mainpanelcontent').load('index.php/c_highlight/highlight_load');
		});
		highlightadd_save.click(function(){
			var id = "";
			var judul = "";
			var image = "";
			var isi = "";
			var link = "";
			var task = "";

			id = highlightpost_id.val();
			image = highlightpost_gambarname.val();
			isi = highlightpost_isi.val();
			judul = highlightpost_judul.val();
			link = highlightpost_link.val();
			task = highlightpost_task.val();

			if(task == ""){
				task = "create";
			}
			$.ajax({
				type : 'POST',
				url : 'index.php/c_highlight/highlight_save',
				data : {
					id : id,
					image : image,
					isi : isi,
					judul : judul,
					link : link,
					task : task
				},success : function(msg){
					var result = eval(msg);
					switch(result){
						case 1:
							$('#mainpanelcontent').empty();
							$('<img src="./images/loader.gif" style="margin:50px auto auto 390px;">').appendTo('#contents');
							$('#mainpanelcontent').load('index.php/c_highlight/highlight_load');
							alert("Data berhasil disimpan");
							break;
						default:
							alert("Data gagal disimpan");
							break;
					}
				}
			});
		});

		<?php
			if(isset($dataDetail)){
		?>
			highlightpost_id.val('<?php echo $dataDetail->id; ?>');
			highlightpost_gambarname.val('<?php echo $dataDetail->image; ?>');
			highlightpost_isi.text('<?php echo $dataDetail->isi; ?>');
			highlightpost_link.val('<?php echo $dataDetail->link; ?>');
			highlightpost_judul.val('<?php echo $dataDetail->judul; ?>');
			highlightpost_task.val('update');

		<?php
			}
		?>


	});

</script>
<!-- Begin content -->
<div class="modal_header">
		<span>Highlight Form</span>
	</div>
<div class="modal_content">
<div id="highlightadd_content">
	<form action="" method="post"  enctype="multipart/form-data" >
		<input type="hidden" id="highlightpost_id">
		<input type="hidden" id="highlightpost_task">
		<p>
			<label>Judul:</label><br/>
			<input type="text" id="highlightpost_judul" class="field_input" style="width:300px"/>
		</p>
		<p>
			<label>Gambar:</label><br/>
			<input type="file" id="highlightpost_gambar" name="userfile" style="width:300px" data-url="<?php echo base_url(); ?>upload/upload_img" />
			<input type="hidden" id="highlightpost_gambarname">
		</p>
		<br/>
		<p>
			<label>Deskripsi:</label><br/>
			<textarea id="highlightpost_isi" cols="50" rows="5" /></textarea>
		</p>
		<br/>
		<p>
			<label>Link :</label><br/>
			<input type="text" id="highlightpost_link" class="field_input" style="width:300px"/>
		</p>
		<br/>
		<p>
			<table align="left">
				<tr align="left">
					<td>
						<div id='highlightadd_save'>
						<img style='float: left; margin: 0px;' src='./images/icons/save.gif' />
						<div style='float: left; margin-left: 4px;'>Simpan</div>
					</div>
					</td>
					<td>
						<div id='highlightadd_cancel'>
						<img style='float: left; margin: 0px;' src='./images/icons/cross.gif' />
						<div style='float: left; margin-left: 4px;'>Cancel</div>
					</div>
					</td>
				</tr>
			</table>
		</p>
		<p>&nbsp;</p>
	</form>
</div>
</div>
<!-- End left column window -->
